<!-- 搜索-顶部悬停 -->
<template>
    <div class="row-wrap">
        <div class="left-wrap">页面上滑时搜索栏顶部悬停</div>
        <div class="right-wrap">
            <el-switch v-model="isFixedTop" />
        </div>
    </div>
</template>

<script>
import { defineComponent, toRefs, computed } from 'vue'
// import { useEditStore } from '@/store'
export default defineComponent({
    name: 'SearchIsFixedTop',
    props: {
        widget: {
            type: Object,
            default: () => ({})
        }
    },
    setup(props) {
        const { widget } = toRefs(props)

        // const editStore = useEditStore()

        // const widgetList = computed(() => editStore.widgetList)

        const isFixedTop = computed({
            get: () => widget.value.widgetData.eles.customFeature.isFixedTop,
            set: val => {
                // if (val) {
                //     // 只允许一个控件吸顶
                //     widgetList.value.forEach(item => {
                //         if (!!item.eles.customFeature.isFixedTop) {
                //             item.eles.customFeature.isFixedTop = false
                //         }
                //     })
                // }
                widget.value.widgetData.eles.customFeature.isFixedTop = val
            }
        })

        return {
            widget,
            isFixedTop
        }
    }
})
</script>

<style lang="less" scoped>
.row-wrap {
    display: flex;
    align-items: center;
    .left-wrap {
        margin-right: 10px;
    }
    .right-wrap {
        // 
    }
}
</style>